//
//  ControllerManger.m
//  囧途
//
//  Created by fly on 16/3/3.
//  Copyright © 2016年 fly. All rights reserved.
//

#import "ControllerManger.h"
#import "LeftViewController.h"
#import "FlyHomeViewController.h"

#import "JTBaseNaviController.h"

@interface ControllerManger ()

@property (nonatomic, strong)DrawerViewController *drawerVC;
@property (nonatomic, strong)FlyHomeViewController * homeVC;

@end
@implementation ControllerManger

/**
 *  单例对象的全局变量
 */
static id _instance;

/**
 *  返回单例对象
 */
+ (instancetype)sharedManager {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [[self alloc] init];
    });
    return _instance;
}

/**
 *  重写单例对象的alloc方法
 */
+ (instancetype)allocWithZone:(struct _NSZone *)zone {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [super allocWithZone:zone];
    });
    return _instance;
}

/**
 *  重写单例对象的copy方法
 */
+ (instancetype)copyWithZone:(struct _NSZone *)zone {
    return _instance;
}

- (UIViewController *)rootVC{
    return self.drawerVC;
}

- (DrawerViewController *)drawerVC{
    if (!_drawerVC) {
        // 这里穿进去的是homeVC并不是导航控制器，  下面哪样初始化没用
        _drawerVC  = [[DrawerViewController alloc] initWithMainViewController:[JTBaseNaviController navigationControllerWithRootViewController:self.homeVC] leftViewController:[LeftViewController new]];
    }
    return _drawerVC;
}
/**
 *  在这里设置了根控制器没用应该你在上面那个方法哪儿初始化传进去的还是homeVC 并不是导航控制器
 */
-(FlyHomeViewController *)homeVC
{
    if (!_homeVC) {
        _homeVC= [[FlyHomeViewController alloc]init];
    }
    return _homeVC;
}

@end
